<?php

class epay_form extends CFormModel {

    public $serial_pin;
    public $transaction_ppob_idpelanggan;
    public $transaction_products_id;
    

    /**
     * Declares the validation rules.
     */
    public function rules() {
        return array(
            //array('serial_pin, jumlah_ditransfer', 'required', 'message' => '{attribute} tidak boleh kososng'),
            //array('transaction_ppob_idpelanggan', 'validasi_payment'),
            array('serial_pin', 'validasi_pin'),
            // verifyCode needs to be entered correctly
            //array('kode_unik', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements(), 'message' => ' Kode unik salah'),
        );
    }

    
    public function validasi_pin($attribute, $params) {

        $pin = $_POST['epay_form']['serial_pin'];
        if (!function_lib::pin_validation(Yii::app()->user->getId(), $pin)) {
//            $messages = Yii::t('yii', "Pin Salah");
//            $this->addError($attribute, $messages);
            $this->addError('serial_pin', 'Pin Anda Salah.');
        }
    }

}

?>
